package orders

import (
	"api/internal/respons"
	"api/internal/svc"
	"api/internal/types"
	"context"
	"order_srv/orderclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type InvoiceLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewInvoiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InvoiceLogic {
	return &InvoiceLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// Invoice 获取发票
func (l *InvoiceLogic) Invoice(req *types.InvoiceRequest) (resp *types.Response, err error) {
	// 业务逻辑
	invoice, err := l.svcCtx.OrderRpc.Invoice(l.ctx, &orderclient.InvoiceRequest{})
	if err != nil {
		return respons.Error(400, "服务端错误", err.Error()), err
	}

	return respons.Success(invoice), nil
}
